﻿using System;

namespace SapaFinance.Domain.Model
{
    public class Bank : AbstractEntity
    {
        protected Bank()
        {

        }

        public  Bank(string bin, string corrAcccount, string name, User user)
            : this()
        {
            Bin = bin;
            CorrespondentAccount = corrAcccount;
            Name = name;
            CreatedBy = new Identity(user);
            Change(user);
        }
        public virtual Identity CreatedBy { get; private set; }
        public virtual Identity ChangedBy { get; private set; }
        public virtual string Bin { get; set; }
        public virtual string Swift { get; set; }
        public virtual string CorrespondentAccount { get; set; }
        public virtual string Name { get; set; }
        public virtual string Address { get; set; }
        public virtual string City { get; set; }
        public virtual bool IsHidden { get; set; }
      
        public void Change(User user)
        {
            ChangedBy = new Identity(user);
        }

        public override bool Equals(object obj)
        {
            var compare = (Bank)obj;
            if (ReferenceEquals(null, compare)) return false;
            if (UID != Guid.Empty) return base.Equals(compare);
            return Bin.Equals(compare.Bin);
        }
    }
}